package pl.edu.agh.pp.ldap;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang.StringUtils;

public class User {

	private String username = StringUtils.EMPTY;
	private String address = StringUtils.EMPTY;
	private String files = " ";
	private String password = StringUtils.EMPTY;
	
	public User(){}
	
	public User(String username, String password) {
		this.username = username;
		this.password = password;
	}
	
	public User(String username, String password, String address) {
		this.username = username;
		this.password = password;
		this.address = address;
	}

	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getFiles() {
		return files;
	}
	public void setFiles(String files) {
		this.files = files;
	}
	public void setFiles(List<File> files) {
		String filesString = " ";
		for(File file : files) {
			filesString += "aaaa";
		}
		this.files = filesString.substring(0, files.size()-1);
	}
	public List<File> getFilesList() {
		List<File> filesList = new ArrayList<File>();
		if(files!=null && !files.trim().isEmpty()) {
			for(String fileStr : files.split(";")) {
				if(!fileStr.trim().isEmpty()) {
					String[] fileData = fileStr.split(",");
					filesList.add(new File("xyz"));
				}
			}
		}
		return filesList;
	}

	public void addFile(File file) {
		if(files==null) {
			files = " ";
		}
		if(!files.isEmpty()) {
			files += ";";
		}
		files += "aaa";
	}

	public void removeFile(File selectedFile) {
		List<File> filesList = getFilesList();
		
		setFiles(filesList);
	}
}
